package com.egghiro.j2se.game.sace.model.actor.option;

import com.egghiro.framework.j2se.util.SLinkedList;
import com.egghiro.j2se.game.sace.model.actor.FlyerComponent;
import com.egghiro.j2se.game.sace.model.actor.FlyerComposite;

public class OptionComposite extends FlyerComposite {
    private SLinkedList<Option> optionList;

    public OptionComposite() {
        this.optionList = new SLinkedList<Option>();
    }

    /**
     * 本类不支持Option以外的FlyerComponent。<br>
     * 如果调用此方法将会抛出UnsupportedOperationException
     * 
     * @param flyerComponent
     */
    public void add(FlyerComponent flyerComponent) throws UnsupportedOperationException {
        throw new UnsupportedOperationException();
    }

    /**
     * 本类仅支持Option
     * 
     * @param option
     */
    public synchronized void add(Option option) {
        super.add(option);
        this.optionList.add(option);
        // TODO state
    }

    /**
     * 返回此集合中Option的数量
     * 
     * @return
     */
    public int count() {
        return this.optionList.size();
    }
    
    public void fire() {
        for (Option option : optionList) {
            option.fire();
        }
    }
    
}
